package com.sfeir.fastcall.model;

/**
 * Created by :
 * 
 * 		@author SFEIR
 */
public class PhoneEntry implements Comparable<PhoneEntry>{


	public String displayName;
	public int id;
	public String phoneNumber;
	public boolean isMobile;
	
	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}
	
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((displayName == null) ? 0 : displayName.hashCode());
		result = prime * result
				+ ((phoneNumber == null) ? 0 : phoneNumber.hashCode());
		return result;
	}
	
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PhoneEntry other = (PhoneEntry) obj;
		if (displayName == null) {
			if (other.displayName != null)
				return false;
		} else if (!displayName.equals(other.displayName))
			return false;
		if (phoneNumber == null) {
			if (other.phoneNumber != null)
				return false;
		} else if (!phoneNumber.equals(other.phoneNumber))
			return false;
		return true;
	}

	@Override
	public int compareTo(PhoneEntry another) {
		if(another == null)
			return 1;
		if(displayName == null)
			return -1;
		int resultDiplayName = displayName.compareTo(another.displayName);
		if(resultDiplayName!=0)
			return resultDiplayName;
		if(phoneNumber == null)
			return -1;		
		return phoneNumber.compareTo(another.phoneNumber);
	}



}
